<%@page import="org.feluma.sgci.controle.Transporte"%>
<%@page import="org.feluma.sgci.dao.PerfilDAO"%>
<%@page import="org.feluma.sgci.dao.UsuarioDAO"%>
<%@page import="org.feluma.sgci.entidade.Usuario"%>
<%@page language="java" contentType="text/html" pageEncoding="ISO-8859-1" %>
<%@page import="org.feluma.sgci.entidade.Perfil" %>
<%@page import="java.util.*" %>
<%@include file="include/usuarioLogado.jsp" %>
<%

Usuario usuario = (Usuario) Transporte.getRequest().getAttribute("usuario");
PerfilDAO daoPer = new PerfilDAO();
ArrayList <Perfil> listaPerfil= (ArrayList<Perfil>) daoPer.listar();
%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>SGCI FCMMG :: Alterar Usuario</title>
    <style type="text/css">
    <!--
    @import url("css/estilo.css");
    body {
    	margin-left: 0px;
        margin-top: 0px;
        margin-right: 0px;
        margin-bottom: 0px;
    }
    -->
    </style>
    <script src="js/utilitarios.js"></script>
</head>
<body background="imagens/fundo.gif" style="background-attachment:fixed">
	<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
    		<td height="7"><jsp:include page="include/topo.jsp" flush="true" /></td>
  		</tr>
  		<tr>
    		<td valign="top">            	   
            	<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
      				<tr>
        				<td height="60">                        
            				<table width="95%" border="0" align="center" cellpadding="1" cellspacing="1">
            					<tr>
              						<td width="76%" class="titulo"><b>Cadastro</b></td>
              						<td width="24%" class="texto">
                        				<div align="right">Usu&aacute;rio logado:<%=usuarioLogado.getNome()%></div>
                        			</td>
            					</tr>
        					</table>
          				</td>
      				</tr>
      				<tr>
        				<td>
                        <fieldset style="border-color:#003366">
                            <legend class="texto"><strong> Altera&ccedil;&atilde;o do Usu&aacute;rio</strong></legend>  
                        	<form name="form1" action="Service" method="post" onSubmit="return validar(this)">                            	
                                <table width="100%" border="0">
                                	 <tr>
                                        <td>&nbsp; </td>
                                       	<td>&nbsp;</td>
                                        <td>&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td width="16%" align="right" class="texto">* Nome: </td>
                                   	  <td width="44%">
                               	      <input name="nome" type="text" class="textBox" id="nome" size="80" maxlength="100" validar="sim" value="<%= usuario.getNome()%>"></td>
                                        <td width="40%"><label id="label_nome" class="texto_atencao" style="visibility:hidden">(* Campo nome vazio!)</label></td>
                                  </tr>
                                    <tr>
                                        <td align="right" class="texto">* Email: </td>
                                   	  <td>
                                   	    <input name="email" type="text" class="textBox" id="email" onBlur="campoEmail(this)" size="80" maxlength="100" validar="sim" value="<%= usuario.getEmail()%>"></td>
                                        <td><label id="label_email" class="texto_atencao" style="visibility:hidden">(* Campo email vazio!)</label></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="texto">* Login: </td>
                                   	  <td>
                                   	    <input name="login" type="text" class="textBox" id="login" maxlength="50" validar="sim" value="<%= usuario.getLogin()%>"></td>
                                        <td><label id="label_login" class="texto_atencao" style="visibility:hidden">(* Campo login vazio!)</label></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="texto">* Senha: </td>
                                   	  <td>
                                   	    <input name="senha" type="password" class="textBox" id="senha" value="" maxlength="50" validar="sim"></td>
                                        <td><label id="label_senha" class="texto_atencao" style="visibility:hidden">(* Campo senha vazio!)</label></td>
                                    </tr>
                                    <tr>
                                         <td align="right" class="texto">* Escola: </td>
                                       	<td>
                                        	<select name="escola" id="escola" validar="sim" class="listBox">
                                                <option value="">... SELECIONE UMA ESCOLA ...</option>
                                                <option value="3" <% if(usuario.getCodEscola()==3) out.print("selected=\"selected\"");%>>CMV</option>
                                                <option value="2" <% if(usuario.getCodEscola()==2) out.print("selected=\"selected\"");%>>CPG</option>                                               
                                            </select>                                        
                                        </td>
                                        <td><label id="label_escola" class="texto_atencao" style="visibility:hidden">(* Campo escola vazio!)</label></td>
                                    </tr>
                                    <tr>
                                        <td align="right" class="texto">* Perfil: </td>
                                       	<td>
                                       		<%if(usuarioLogado.getPerfil().getCodigo() == 1) {%>
                                        	<select name="perfil" id="perfil" validar="sim" class="listBox">
                                                <option value="">....  SELECIONE UM PERFIL  .....</option>
                                                <% 
                                                	Perfil objPerfil = new Perfil();
                                                	for(int i=0; i < listaPerfil.size();i++)
                                                	{ objPerfil = (Perfil) listaPerfil.get(i);
                                                %>
                                                	<option value="<%=objPerfil.getCodigo()%>" <% if(usuario.getPerfil().getCodigo()==objPerfil.getCodigo()) out.print("selected=\"selected\"");%> ><%=objPerfil.getDescricao()%></option>
                                                <%  }	%>                                              
                                            </select>
                                            <%} else { %>
                                            <select name="perfil" id="perfil" validar="sim" class="listBox">
                                                <option value="<%=usuario.getCodigo()%>" selected="selected" ><%=usuario.getPerfil().getDescricao()%></option>                                            
                                            </select> 
                                           <%} %> 
                                        </td>
                                        <td><label id="label_perfil" class="texto_atencao" style="visibility:hidden">(* Campo perfil vazio!)</label></td>
                                    </tr>
                                    <tr>
                                        <td>&nbsp; </td>
                                       	<td>&nbsp;</td>
                                        <td><input name="classe" type="hidden" value="org.feluma.sgci.controle.UsuarioControle">
                                            <input name="acao" type="hidden" value="gravar">
                                            <input name="codigo" type="hidden" value="<%= usuario.getCodigo() %>">
                                            <input name="usuarioLogado" type="hidden" value="<%=usuarioLogado.getCodigo()%>"></td>
                                    </tr>
                                    <tr>
                                        <td colspan="3" align="center" ><input type="submit" name="cadastrar" id="cadastrar" value="Gravar"></td>
                                   	</tr>
                                </table>
                            </form>
                          </fieldset>
                      </td>
      				</tr>
      				<tr>
        				<td>&nbsp;</td>
      				</tr>
    			</table>
                
    		</td>
  		</tr>
  		<tr>
    		<td height="15">
	    		<% 
				int codEscola = usuarioLogado.getCodEscola();
	    		if (codEscola == 2){%>
	    			<jsp:include page="include/rodapeCpg.jsp" flush="true" />
	    		
	    		<%} else if (codEscola ==3){%>
	    			<jsp:include page="include/rodapeCmv.jsp" flush="true" />
	    		<%} else {%>
	    			<jsp:include page="include/rodape.jsp" flush="true" />
	    		<%} %>
    		</td>
  		</tr>
	</table>
</body>
</html>